package person.bing.fbcloud.leetcode;

import person.bing.fbcloud.Test;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author: mengfanbing
 * @date: 2020/9/29 9:40
 */
public class Q145 {
    public static void main(String[] args) {
        Test test = new Test();
    }
    public static List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> ans = new ArrayList<>();
        util(ans,root);
        return ans;
    }
    public static void util(List<Integer> ans,TreeNode root) {
        if(root == null){
            return;
        }
        util(ans,root.left);
        util(ans,root.right);
        ans.add(root.val);
    }



    private class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
    }
}
